package cn.com.zpark.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @PackageName: cn.com.zpark.cookie
 * @ClassName: CookieDemo03
 * @Description:
 * @author: RZS
 * @date: 2021/11/16  17:13
 */
@WebServlet("/cd3.do")
public class CookieDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 创建cookie对象
        Cookie cookie1 = new Cookie("dc", "dachui");
        Cookie cookie2 = new Cookie("name", "张三");

        cookie1.setMaxAge(60*3);
        cookie2.setValue("zhangsan");

        // 将cookie对象发送到浏览器
        response.addCookie(cookie1);
        response.addCookie(cookie2);
    }
}
